package com.situ.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bean.Customers;
import com.service.ICustomerService;
import com.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("customer")
public class CustomersController {
     @Autowired
     ICustomerService customersService;

    @PostMapping("")
    public ResultData  insert(@RequestBody Customers customers) {
        System.out.println(customers);
        return ResultData.success(customersService.insert(customers));
    }

    @PutMapping("")
    public ResultData  update(@RequestBody Customers customers) {
        return ResultData.success(customersService.update(customers));
    }

    @GetMapping("/{id}")
    public ResultData  getById(@PathVariable Integer id) {
        return ResultData.success(customersService.getById(id));
    }

    @DeleteMapping("/{id}")
    public ResultData deleteById(@PathVariable Integer id) {
        return ResultData.success(customersService.deleteById(id));
    }

    @GetMapping("/page")
    public ResultData  getListByPage(IPage<Customers> page, Customers customers) {
        return ResultData.success(customersService.getListByPage(page, customers));
    }

    @GetMapping("/list")
    public ResultData  getList(Customers customers) {
        return ResultData.success(customersService.getList(customers));
    }




}
